MapInterface

interface MapInterface : CameraManagerInterface

Map class provides map rendering functionality.

Functions

addPersistentStyleCustomLayer
Link copied to clipboard
abstract fun addPersistentStyleCustomLayer(@NonNull() layerId: String, @NonNull() layerHost: CustomLayerHost, @Nullable() layerPosition: LayerPosition): Expected<String, None>
Adds a new [style custom layer](https://docs.mapbox.com/mapbox-gl-js/style-spec/#layers).Note: This is an experimental API and is a subject to change.Whenever a new style is being parsed and currently used style has persistent layers,an engine will try to do following:- keep the persistent layer at its relative position- keep the source used by a persistent layer- keep images added through `addStyleImage` methodIn cases when a new style has the same layer, source or image resource, style's resources would beused instead and `MapLoadingError` event will be emitted.
addPersistentStyleLayer
Link copied to clipboard
abstract fun addPersistentStyleLayer(@NonNull() properties: Value, @Nullable() layerPosition: LayerPosition): Expected<String, None>
Adds a new [style layer](https://docs.mapbox.com/mapbox-gl-js/style-spec/#layers).Note: This is an experimental API and is a subject to change.Whenever a new style is being parsed and currently used style has persistent layers,an engine will try to do following:- keep the persistent layer at its relative position- keep the source used by a persistent layer- keep images added through `addStyleImage` methodIn cases when a new style has the same layer, source or image resource, style's resources would beused instead and `MapLoadingError` event will be emitted.
addStyleCustomGeometrySource
Link copied to clipboard
abstract fun addStyleCustomGeometrySource(@NonNull() sourceId: String, @NonNull() options: CustomGeometrySourceOptions): Expected<String, None>
Adds a custom geometry to be used in the style.
addStyleCustomLayer
Link copied to clipboard
abstract fun addStyleCustomLayer(@NonNull() layerId: String, @NonNull() layerHost: CustomLayerHost, @Nullable() layerPosition: LayerPosition): Expected<String, None>
Adds a new [style custom layer](https://docs.mapbox.com/mapbox-gl-js/style-spec/#layers).Runtime style layers are valid until they are either removed or a new style is loaded.
addStyleImage
Link copied to clipboard
abstract fun addStyleImage(@NonNull() imageId: String, scale: Float, @NonNull() image: Image, sdf: Boolean, @NonNull() stretchX: List<ImageStretches>, @NonNull() stretchY: List<ImageStretches>, @Nullable() content: ImageContent): Expected<String, None>
Adds an image to be used in the style.
addStyleLayer
Link copied to clipboard
abstract fun addStyleLayer(@NonNull() properties: Value, @Nullable() layerPosition: LayerPosition): Expected<String, None>
Adds a new [style layer](https://docs.mapbox.com/mapbox-gl-js/style-spec/#layers).Runtime style layers are valid until they are either removed or a new style is loaded.
addStyleSource
Link copied to clipboard
abstract fun addStyleSource(@NonNull() sourceId: String, @NonNull() properties: Value): Expected<String, None>
Adds a new [style source](https://docs.mapbox.com/mapbox-gl-js/style-spec/#sources).
cameraForCoordinateBounds
Link copied to clipboard
abstract fun cameraForCoordinateBounds(@NonNull() bounds: CoordinateBounds, @NonNull() padding: EdgeInsets, @Nullable() bearing: Double, @Nullable() pitch: Double): CameraOptions
Convenience method that returns the `camera options` object for given parameters.
cameraForCoordinates
Link copied to clipboard
abstract fun cameraForCoordinates(@NonNull() coordinates: List<Point>, @NonNull() camera: CameraOptions, @NonNull() box: ScreenBox): CameraOptions
Convenience method that adjusts the provided `camera options` object for given parameters.Returns the provided `camera` options with zoom adjusted to fit `coordinates` into the `box`, so that `coordinates` on the left,top and right of the effective `camera` center at the principal point of the projection (defined by `padding`) fit into the `box`.Returns the provided `camera` options object unchanged upon an error.Note that this method may fail if the principal point of the projection is not inside the `box` orif there is no sufficient screen space, defined by principal point and the `box`, to fit the geometry.
abstract fun cameraForCoordinates(@NonNull() coordinates: List<Point>, @NonNull() padding: EdgeInsets, @Nullable() bearing: Double, @Nullable() pitch: Double): CameraOptions
Convenience method that returns the `camera options` object for given parameters.
cameraForGeometry
Link copied to clipboard
abstract fun cameraForGeometry(@NonNull() geometry: Geometry, @NonNull() padding: EdgeInsets, @Nullable() bearing: Double, @Nullable() pitch: Double): CameraOptions
Convenience method that returns the `camera options` object for given parameters.
coordinateBoundsForCamera
Link copied to clipboard
abstract fun coordinateBoundsForCamera(@NonNull() camera: CameraOptions): CoordinateBounds
Returns the `coordinate bounds` for a given camera.Note that if the given `camera` shows the antimeridian, the returned wrapped `coordinate bounds`might not represent the minimum bounding box.
coordinateBoundsZoomForCamera
Link copied to clipboard
abstract fun coordinateBoundsZoomForCamera(@NonNull() camera: CameraOptions): CoordinateBoundsZoom
Returns the `coordinate bounds` and the `zoom` for a given `camera`.Note that if the given `camera` shows the antimeridian, the returned wrapped `coordinate bounds`might not represent the minimum bounding box.
coordinateBoundsZoomForCameraUnwrapped
Link copied to clipboard
abstract fun coordinateBoundsZoomForCameraUnwrapped(@NonNull() camera: CameraOptions): CoordinateBoundsZoom
Returns the unwrapped `coordinate bounds` and `zoom` for a given `camera`.This method is particularly useful, if the `camera` shows the antimeridian.
coordinateForPixel
Link copied to clipboard
abstract fun coordinateForPixel(@NonNull() pixel: ScreenCoordinate): Point
Calculates a geographical `coordinate` (i.e., longitude-latitude pair) that correspondsto a `screen coordinate`.The screen coordinate is in `platform pixels`relative to the top left cornerof the map (not of the whole screen).
coordinatesForPixels
Link copied to clipboard
abstract fun coordinatesForPixels(@NonNull() pixels: List<ScreenCoordinate>): List<Point>
Calculates geographical `coordinates` (i.e., longitude-latitude pairs) that correspondto `screen coordinates`.The screen coordinates are in `platform pixels` relative to the top left cornerof the map (not of the whole screen).
createRenderer
Link copied to clipboard
abstract fun createRenderer()
Creates the infrastructure needed for rendering the map.It should be called before any call to `render` method.
destroyRenderer
Link copied to clipboard
abstract fun destroyRenderer()
Destroys the infrastructure needed for rendering the map, releasing resources.Must be called on the render thread.
dragEnd
Link copied to clipboard
abstract fun dragEnd()
Ends the ongoing drag gesture.
dragStart
Link copied to clipboard
abstract fun dragStart(@NonNull() point: ScreenCoordinate)
Prepares the drag gesture to use the provided screen coordinate as a pivot `point`.
getBounds
Link copied to clipboard
abstract fun getBounds(): CameraBounds
Returns the `camera bounds` of the map.
getCameraState
Link copied to clipboard
abstract fun getCameraState(): CameraState
Returns the current `camera state`.
getDebug
Link copied to clipboard
abstract fun getDebug(): List<MapDebugOptions>
Returns the `map debug options`.
getDragCameraOptions
Link copied to clipboard
abstract fun getDragCameraOptions(@NonNull() fromPoint: ScreenCoordinate, @NonNull() toPoint: ScreenCoordinate): CameraOptions
Calculates target point where camera should move after drag.
getElevation
Link copied to clipboard
abstract fun getElevation(@NonNull() coordinate: Point): Double
Gets elevation for the given coordinate.Note: Elevation is only available for the visible region on the screen.
getFeatureState
Link copied to clipboard
abstract fun getFeatureState(@NonNull() sourceId: String, @Nullable() sourceLayerId: String, @NonNull() featureId: String, @NonNull() callback: QueryFeatureStateCallback)
Gets the state map of a feature within a style source.Note that updates to feature state are asynchronous, so changes made by other methods might not beimmediately visible.
getFreeCameraOptions
Link copied to clipboard
abstract fun getFreeCameraOptions(): FreeCameraOptions
Gets the map's current free camera options.
getMapOptions
Link copied to clipboard
abstract fun getMapOptions(): MapOptions
Returns the `map options`.
getMapProjection
Link copied to clipboard
abstract fun getMapProjection(): Value
Returns the currently active map projection and its properties as key-value pairs.Common properties shared by all map projections are:- "name" with possible values "mercator" or "globe".
getPrefetchZoomDelta
Link copied to clipboard
abstract fun getPrefetchZoomDelta(): Byte
Returns the map's prefetch zoom delta.
getRenderCacheOptions
Link copied to clipboard
abstract fun getRenderCacheOptions(): RenderCacheOptions
Returns the `render cache options` used by the map.
getResourceOptions
Link copied to clipboard
abstract fun getResourceOptions(): ResourceOptions
Gets the resource options for the map.All optional fields of the retuned object are initialized with the actual values.Note that result of this method is different from the `resource options` that were provided to the map's constructor.
getSize
Link copied to clipboard
abstract fun getSize(): Size
Gets the size of the map.
getStyleDefaultCamera
Link copied to clipboard
abstract fun getStyleDefaultCamera(): CameraOptions
Returns the map style's default camera, if any, or a default camera otherwise.The map style's default camera is defined as follows:- [center](https://docs.mapbox.com/mapbox-gl-js/style-spec/#root-center)- [zoom](https://docs.mapbox.com/mapbox-gl-js/style-spec/#root-zoom)- [bearing](https://docs.mapbox.com/mapbox-gl-js/style-spec/#root-bearing)- [pitch](https://docs.mapbox.com/mapbox-gl-js/style-spec/#root-pitch)The style default camera is re-evaluated when a new style is loaded.
getStyleImage
Link copied to clipboard
abstract fun getStyleImage(@NonNull() imageId: String): Image
Get an `image` from the style.
getStyleJSON
Link copied to clipboard
abstract fun getStyleJSON(): String
Get the JSON serialization string of the current style in use.
getStyleLayerProperties
Link copied to clipboard
abstract fun getStyleLayerProperties(@NonNull() layerId: String): Expected<String, Value>
Gets style layer properties.
getStyleLayerProperty
Link copied to clipboard
abstract fun getStyleLayerProperty(@NonNull() layerId: String, @NonNull() property: String): StylePropertyValue
Gets the value of style layer property.
getStyleLayers
Link copied to clipboard
abstract fun getStyleLayers(): List<StyleObjectInfo>
Returns the existing style layers.
getStyleLightProperty
Link copied to clipboard
abstract fun getStyleLightProperty(@NonNull() property: String): StylePropertyValue
Gets the value of a style light property.
getStyleSourceProperties
Link copied to clipboard
abstract fun getStyleSourceProperties(@NonNull() sourceId: String): Expected<String, Value>
Gets style source properties.
getStyleSourceProperty
Link copied to clipboard
abstract fun getStyleSourceProperty(@NonNull() sourceId: String, @NonNull() property: String): StylePropertyValue
Gets the value of style source property.
getStyleSources
Link copied to clipboard
abstract fun getStyleSources(): List<StyleObjectInfo>
Returns the existing style sources.
getStyleTerrainProperty
Link copied to clipboard
abstract fun getStyleTerrainProperty(@NonNull() property: String): StylePropertyValue
Gets the value of a style terrain property.
getStyleTransition
Link copied to clipboard
abstract fun getStyleTransition(): TransitionOptions
Returns the map style's transition options.
getStyleURI
Link copied to clipboard
abstract fun getStyleURI(): String
Get the URI of the current style in use.
abstract fun invalidateStyleCustomGeometrySourceRegion(@NonNull() sourceId: String, @NonNull() bounds: CoordinateBounds): Expected<String, None>
Invalidate region for provided custom geometry source.
invalidateStyleCustomGeometrySourceTile
Link copied to clipboard
abstract fun invalidateStyleCustomGeometrySourceTile(@NonNull() sourceId: String, @NonNull() tileId: CanonicalTileID): Expected<String, None>
Invalidate tile for provided custom geometry source.
isGestureInProgress
Link copied to clipboard
abstract fun isGestureInProgress(): Boolean
Returns `true` if a gesture is currently in progress.
isMapLoaded
Link copied to clipboard
abstract fun isMapLoaded(): Boolean
Returns `true` when the map is completely rendered, `false` otherwise.
isStyleLayerPersistent
Link copied to clipboard
abstract fun isStyleLayerPersistent(@NonNull() layerId: String): Expected<String, Boolean>
Checks if a style layer is persistent.Note: This is an experimental API and is a subject to change.
isStyleLoaded
Link copied to clipboard
abstract fun isStyleLoaded(): Boolean
Check if the style is completely loaded.Note: The style specified sprite would be marked as loaded even with sprite loading error (An error will be emitted via `MapLoadingError`).Sprite loading error is not fatal and we don't want it to block the map rendering, thus the function will still return `true` if style and sources are fully loaded.
isUserAnimationInProgress
Link copied to clipboard
abstract fun isUserAnimationInProgress(): Boolean
Returns `true` if user animation is currently in progress.
moveStyleLayer
Link copied to clipboard
abstract fun moveStyleLayer(@NonNull() layerId: String, @Nullable() layerPosition: LayerPosition): Expected<String, None>
Moves an existing style layer
pixelForCoordinate
Link copied to clipboard
abstract fun pixelForCoordinate(@NonNull() coordinate: Point): ScreenCoordinate
Calculates a `screen coordinate` that corresponds to a geographical coordinate(i.e., longitude-latitude pair).The `screen coordinate` is in `platform pixels` relative to the top left cornerof the map (not of the whole screen).
pixelsForCoordinates
Link copied to clipboard
abstract fun pixelsForCoordinates(@NonNull() coordinates: List<Point>): List<ScreenCoordinate>
Calculates `screen coordinates` that correspond to geographical `coordinates`(i.e., longitude-latitude pairs).The `screen coordinates` are in `platform pixels` relative to the top left cornerof the map (not of the whole screen).
queryFeatureExtensions
Link copied to clipboard
abstract fun queryFeatureExtensions(@NonNull() sourceIdentifier: String, @NonNull() feature: Feature, @NonNull() extension: String, @NonNull() extensionField: String, @Nullable() args: HashMap<String, Value>, @NonNull() callback: QueryFeatureExtensionCallback)
Queries for feature extension values in a GeoJSON source.
queryRenderedFeatures
Link copied to clipboard
abstract fun queryRenderedFeatures(@NonNull() box: ScreenBox, @NonNull() options: RenderedQueryOptions, @NonNull() callback: QueryFeaturesCallback)
Queries the map for rendered features.
abstract fun queryRenderedFeatures(@NonNull() pixel: ScreenCoordinate, @NonNull() options: RenderedQueryOptions, @NonNull() callback: QueryFeaturesCallback)
Queries the map for rendered features.
abstract fun queryRenderedFeatures(@NonNull() shape: List<ScreenCoordinate>, @NonNull() options: RenderedQueryOptions, @NonNull() callback: QueryFeaturesCallback)
Queries the map for rendered features.
querySourceFeatures
Link copied to clipboard
abstract fun querySourceFeatures(@NonNull() sourceId: String, @NonNull() options: SourceQueryOptions, @NonNull() callback: QueryFeaturesCallback)
Queries the map for source features.
reduceMemoryUse
Link copied to clipboard
abstract fun reduceMemoryUse()
Reduces memory use.
removeFeatureState
Link copied to clipboard
abstract fun removeFeatureState(@NonNull() sourceId: String, @Nullable() sourceLayerId: String, @NonNull() featureId: String, @Nullable() stateKey: String)
Removes entries from a feature state object.Remove a specified property or all property from a feature's state object, depending on the value of`stateKey`.Note that updates to feature state are asynchronous, so changes made by this method migth not beimmediately visible using `getStateFeature`.
removeStyleImage
Link copied to clipboard
abstract fun removeStyleImage(@NonNull() imageId: String): Expected<String, None>
Removes an image from the style.
removeStyleLayer
Link copied to clipboard
abstract fun removeStyleLayer(@NonNull() layerId: String): Expected<String, None>
Removes an existing style layer.
removeStyleSource
Link copied to clipboard
abstract fun removeStyleSource(@NonNull() sourceId: String): Expected<String, None>
Removes an existing style source.
render
Link copied to clipboard
abstract fun render()
Renders the map.
setBounds
Link copied to clipboard
abstract fun setBounds(@NonNull() options: CameraBoundsOptions): Expected<String, None>
Sets the `camera bounds options` of the map.
setCamera
Link copied to clipboard
abstract fun setCamera(@NonNull() cameraOptions: CameraOptions)
Changes the map view by any combination of center, zoom, bearing, and pitch, without an animated transition.The map will retain its current values for any details not passed via the camera options argument.It is not guaranteed that the provided `camera options` will be set, the map may apply constraints resulting in adifferent `camera state`.
abstract fun setCamera(@NonNull() freeCameraOptions: FreeCameraOptions)
Sets the map view with the free camera options.The `free camera options` provides more direct access to the underlying camera entity.For backwards compatibility the state set using this API must be representable with`camera options` as well.
setConstrainMode
Link copied to clipboard
abstract fun setConstrainMode(@NonNull() mode: ConstrainMode)
Sets the map `constrain mode`.
setDebug
Link copied to clipboard
abstract fun setDebug(@NonNull() debugOptions: List<MapDebugOptions>, value: Boolean)
Sets the `map debug options` and enables debug mode based on the passed value.
setFeatureState
Link copied to clipboard
abstract fun setFeatureState(@NonNull() sourceId: String, @Nullable() sourceLayerId: String, @NonNull() featureId: String, @NonNull() state: Value)
Updates the state object of a feature within a style source.Update entries in the `state` object of a given feature within a style source.
setGestureInProgress
Link copied to clipboard
abstract fun setGestureInProgress(inProgress: Boolean)
Tells the map rendering engine that there is currently a gesture in progress.
setMapProjection
Link copied to clipboard
abstract fun setMapProjection(@NonNull() projection: Value): Expected<String, None>
Updates the active map projection.
setNorthOrientation
Link copied to clipboard
abstract fun setNorthOrientation(@NonNull() orientation: NorthOrientation)
Sets the north `orientation mode`.
setPrefetchZoomDelta
Link copied to clipboard
abstract fun setPrefetchZoomDelta(delta: Byte)
When loading a map, if prefetch zoom `delta` is set to any number greater than 0,the map will first request a tile at zoom level lower than `zoom - delta`, with requestedzoom level a multiple of `delta`, in an attempt to display a full map at lower resolution as quick as possible.
setRenderCacheOptions
Link copied to clipboard
abstract fun setRenderCacheOptions(@NonNull() options: RenderCacheOptions)
Enables or disables the experimental render cache feature.Render cache is an experimental feature aiming to reduce resource usage of map renderingby caching intermediate rendering results of tiles into specific cache textures for reuse between frames.Performance benefit of the cache depends on the style as not all layers are cacheable due to e.g.viewport aligned features.
setSize
Link copied to clipboard
abstract fun setSize(@NonNull() size: Size)
Sets the size of the map.
setStyleCustomGeometrySourceTileData
Link copied to clipboard
abstract fun setStyleCustomGeometrySourceTileData(@NonNull() sourceId: String, @NonNull() tileId: CanonicalTileID, @NonNull() featureCollection: List<Feature>): Expected<String, None>
Set tile data of a custom geometry.
setStyleJSON
Link copied to clipboard
abstract fun setStyleJSON(@NonNull() json: String)
Load the style from a provided JSON string.
setStyleLayerProperties
Link copied to clipboard
abstract fun setStyleLayerProperties(@NonNull() layerId: String, @NonNull() properties: Value): Expected<String, None>
Sets style layer properties.This method can be used to perform batch update for a style layer properties.
setStyleLayerProperty
Link copied to clipboard
abstract fun setStyleLayerProperty(@NonNull() layerId: String, @NonNull() property: String, @NonNull() value: Value): Expected<String, None>
Sets a value to a style layer property.
setStyleLight
Link copied to clipboard
abstract fun setStyleLight(@NonNull() properties: Value): Expected<String, None>
Sets the style global [light](https://docs.mapbox.com/mapbox-gl-js/style-spec/#light) properties.
setStyleLightProperty
Link copied to clipboard
abstract fun setStyleLightProperty(@NonNull() property: String, @NonNull() value: Value): Expected<String, None>
Sets a value to the the style light property.
setStyleSourceProperties
Link copied to clipboard
abstract fun setStyleSourceProperties(@NonNull() sourceId: String, @NonNull() properties: Value): Expected<String, None>
Sets style source properties.This method can be used to perform batch update for a style source properties.
setStyleSourceProperty
Link copied to clipboard
abstract fun setStyleSourceProperty(@NonNull() sourceId: String, @NonNull() property: String, @NonNull() value: Value): Expected<String, None>
Sets a value to a style source property.Note: When setting the `data` property of a `geojson` source, this method never returns an error.In case of success, a `map-loaded` event will be propagated.
setStyleTerrain
Link copied to clipboard
abstract fun setStyleTerrain(@NonNull() properties: Value): Expected<String, None>
Sets the style global [terrain](https://docs.mapbox.com/mapbox-gl-js/style-spec/#terrain) properties.
setStyleTerrainProperty
Link copied to clipboard
abstract fun setStyleTerrainProperty(@NonNull() property: String, @NonNull() value: Value): Expected<String, None>
Sets a value to the the style terrain property.
setStyleTransition
Link copied to clipboard
abstract fun setStyleTransition(@NonNull() transitionOptions: TransitionOptions)
Overrides the map style's transition options with user-provided options.The style transition is re-evaluated when a new style is loaded.
setStyleURI
Link copied to clipboard
abstract fun setStyleURI(@NonNull() uri: String)
Load style from provided URI.This is an asynchronous call.
setUserAnimationInProgress
Link copied to clipboard
abstract fun setUserAnimationInProgress(inProgress: Boolean)
Tells the map rendering engine that the animation is currently performed by theuser (e.g.
setViewportMode
Link copied to clipboard
abstract fun setViewportMode(@NonNull() mode: ViewportMode)
Sets the `viewport mode`.
styleLayerExists
Link copied to clipboard
abstract fun styleLayerExists(@NonNull() layerId: String): Boolean
Checks whether a given style layer exists.
styleSourceExists
Link copied to clipboard
abstract fun styleSourceExists(@NonNull() sourceId: String): Boolean
Checks whether a given style source exists.
subscribe
Link copied to clipboard
abstract fun subscribe(@NonNull() observer: Observer, @NonNull() events: List<String>)
Subscribes an `observer` to a provided array of event types.The `observable` will hold a strong reference to an `observer` instance, therefore,in order to stop receiving notifications, caller must call `unsubscribe` with an`observer` instance used for an initial subscription.
triggerRepaint
Link copied to clipboard
abstract fun triggerRepaint()
Triggers a repaint of the map.
unsubscribe
Link copied to clipboard
abstract fun unsubscribe(@NonNull() observer: Observer)
Unsubscribes an `observer` from all events.
abstract fun unsubscribe(@NonNull() observer: Observer, @NonNull() events: List<String>)
Unsubscribes an `observer` from a provided array of event types.
updateStyleImageSourceImage
Link copied to clipboard
abstract fun updateStyleImageSourceImage(@NonNull() sourceId: String, @NonNull() image: Image): Expected<String, None>
Updates the image of an [image style source](https://docs.mapbox.com/mapbox-gl-js/style-spec/#sources-image).